package Tool;

import java.sql.*;

public class MySQL_IsUserLoginTrue {
    public static boolean Logintrue(Connection conn, String name, String userpassword) throws SQLException {

        //定义sql

        //查询
        String sql = "select * from user where ID = ? and PassWord = ?";
        //获取执行psql的对象  PreparedStatement
        PreparedStatement pstmt = conn.prepareStatement(sql);
        //设置？的值
        pstmt.setString(1, name);
        pstmt.setString(2, userpassword);
        //执行sql语句
        ResultSet rs = pstmt.executeQuery();

        //处理结果
        if (rs.next()){
            //释放资源
            rs.close();
            pstmt.close();

            return true;
        }else {
            //释放资源
            rs.close();
            pstmt.close();
            return false;
        }

    }
}
